﻿using HCMS.Entities.Manage;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;

namespace HCMS.Repositories.Manage
{
    /// <summary>
    /// 管理系统 连接池
    /// </summary>
    [ConnectionStringName("Manage")]
    public class ManageDbContext :
        AbpDbContext<ManageDbContext>
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="options"></param>
        public ManageDbContext(DbContextOptions<ManageDbContext> options)
            : base(options)
        {

        }

        #region 注册实体
        /// <summary>
        /// 管理员
        /// </summary>
        public DbSet<Admin> Admin { get; set; }

        /// <summary>
        /// 管理员 角色
        /// </summary>
        public DbSet<AdminRole> AdminRole { get; set; }

        /// <summary>
        /// 角色
        /// </summary>
        public DbSet<Role> Role { get; set; }

        /// <summary>
        /// 角色 菜单
        /// </summary>
        public DbSet<RoleMenu> RoleMenu { get; set; }

        /// <summary>
        /// 菜单
        /// </summary>
        public DbSet<Menu> Menu { get; set; }

        /// <summary>
        /// 管理员 登录 日志
        /// </summary>
        public DbSet<AdminLoginLogs> AdminLoginLogs { get; set; }

        /// <summary>
        /// 管理员 操作 日志
        /// </summary>
        public DbSet<AdminActionLogs> AdminActionLogs { get; set; }
        #endregion

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            /* Include modules to your migration db context */

            // builder.ConfigureBackgroundJobs();
            // builder.ConfigureAuditLogging();
            // builder.ConfigureOpenIddict();
            // builder.ConfigureBlobStoring();

            /* Configure your own tables/entities inside here */

            //builder.Entity<YourEntity>(b =>
            //{
            //    b.ToTable(HCMSConsts.DbTablePrefix + "YourEntities", HCMSConsts.DbSchema);
            //    b.ConfigureByConvention(); //auto configure for the base class props
            //    //...
            //});
        }
    }
}
